package org.ehe.finance.receivable.domain.bo;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.ehe.common.core.validate.AddGroup;
import org.ehe.common.core.validate.EditGroup;
import org.ehe.common.mybatis.core.domain.BaseEntity2;
import org.ehe.finance.receivable.domain.ErpFinanceReceivable;

import jakarta.validation.constraints.*;
import java.math.BigDecimal;
import java.time.LocalDate;
/**
 * 应收账款BO
 * @author :zhangnn
 * @className :ErpFinanceReceivableBo
 * @description: TODO
 * @date 2025-08-28 09:28:36
 */
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = ErpFinanceReceivable.class, reverseConvertGenerate = false)
public class ErpFinanceReceivableBo extends BaseEntity2 {

    /**
     * 应收账款ID
     */
    @NotNull(message = "应收账款ID不能为空", groups = { EditGroup.class })
    private Long id;

    /**
     * 单据编号
     */
    @NotBlank(message = "单据编号不能为空", groups = { AddGroup.class, EditGroup.class })
    @Size(max = 50, message = "单据编号长度不能超过50个字符")
    private String billNo;

    /**
     * 客户ID
     */
    @NotNull(message = "客户ID不能为空", groups = { AddGroup.class, EditGroup.class })
    private Long customerId;

    /**
     * 单据日期
     */
    @NotNull(message = "单据日期不能为空", groups = { AddGroup.class, EditGroup.class })
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate billDate;

    /**
     * 单据类型:1销售发票,2其他应收
     */
    @NotNull(message = "单据类型不能为空", groups = { AddGroup.class, EditGroup.class })
    @Min(value = 1, message = "单据类型值必须为1或2")
    @Max(value = 2, message = "单据类型值必须为1或2")
    private Integer billType;

    /**
     * 来源单据号
     */
    @Size(max = 50, message = "来源单据号长度不能超过50个字符")
    private String sourceBillNo;

    /**
     * 应收总金额
     */
    @NotNull(message = "应收总金额不能为空", groups = { AddGroup.class, EditGroup.class })
    @DecimalMin(value = "0.00", message = "应收总金额不能小于0")
    @Digits(integer = 16, fraction = 2, message = "应收总金额格式不正确")
    private BigDecimal totalAmount;

    /**
     * 已收款金额
     */
    @DecimalMin(value = "0.00", message = "已收款金额不能小于0")
    @Digits(integer = 16, fraction = 2, message = "已收款金额格式不正确")
    private BigDecimal paidAmount;

    /**
     * 未收款金额
     */
    @DecimalMin(value = "0.00", message = "未收款金额不能小于0")
    @Digits(integer = 16, fraction = 2, message = "未收款金额格式不正确")
    private BigDecimal unpaidAmount;

    /**
     * 到期日期
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate dueDate;

    /**
     * 币种ID
     */
    @NotNull(message = "币种ID不能为空", groups = { AddGroup.class, EditGroup.class })
    private Long currencyId;

    /**
     * 汇率
     */
    @DecimalMin(value = "0.0001", message = "汇率不能小于0.0001")
    @Digits(integer = 6, fraction = 4, message = "汇率格式不正确")
    private BigDecimal exchangeRate;

    /**
     * 部门ID
     */
    private Long departmentId;

    /**
     * 业务员ID
     */
    private Long salesmanId;

    /**
     * 结算状态:1未结算,2部分结算,3已结算
     */
    @Min(value = 1, message = "结算状态值必须为1、2或3")
    @Max(value = 3, message = "结算状态值必须为1、2或3")
    private Integer settlementStatus;

    /**
     * 备注
     */
    @Size(max = 255, message = "备注长度不能超过255个字符")
    private String remark;

    // 查询条件字段
    /**
     * 客户名称（模糊查询）
     */
    private String customerName;

    /**
     * 结算状态列表（多选查询）
     */
    private Integer[] settlementStatusList;

    /**
     * 单据日期开始
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate billDateStart;

    /**
     * 单据日期结束
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate billDateEnd;

    /**
     * 到期日期开始
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate dueDateStart;

    /**
     * 到期日期结束
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate dueDateEnd;

    /**
     * 是否逾期
     */
    private Boolean isOverdue;
}
